{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1dee26d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import random\n",
    "\n",
    "# 准备数据\n",
    "x_data = [f\"20{i}年\" for i in range(16, 21)]\n",
    "y_data = [random.randint(100, 300) for i in range(6)]\n",
    "\n",
    "# 正确显示中文和负号\n",
    "plt.rcParams[\"font.sans-serif\"] = [\"SimHei\"]\n",
    "plt.rcParams[\"axes.unicode_minus\"] = False\n",
    "\n",
    "# 画图，plt.bar()可以画柱状图\n",
    "for i in range(len(x_data)):\n",
    "\tplt.bar(x_data[i], y_data[i])\n",
    "# 设置图片名称\n",
    "plt.title(\"销量分析\")\n",
    "# 设置x轴标签名\n",
    "plt.xlabel(\"年份\")\n",
    "# 设置y轴标签名\n",
    "plt.ylabel(\"销量\")\n",
    "# 显示\n",
    "plt.show()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
